package mysql

import (
	"database/sql"
	"github.com/pkg/errors"
	"app/model"
	_ "github.com/go-sql-driver/mysql"
)

type db struct {
	*sql.DB
}

func NewDb(dsn string) (model.DB,error) {
	d , err := sql.Open("mysql",dsn)

	if err != nil {
		return nil, errors.Wrap(err,"connect mysql failed")
	}
	idb := new(db)
	idb.DB = d

	return idb, nil
}
